<template>
    <div>
        <header>
            <div class="title">
                <span class="titles">趣游后台管理系统</span>
                <span class="titles" :class="{ active: activeTab === 'one' }" @click="changeTab('one')"
                    style="cursor: pointer;">用户管理</span>
                <span class="titles" :class="{ active: activeTab === 'two' }" @click="changeTab('two')"
                    style="cursor: pointer;">稿件管理</span>
                <span class="titles" :class="{ active: activeTab === 'three' }" @click="changeTab('three')"
                    style="cursor: pointer;">上传审核</span>
                <span class="titles" :class="{ active: activeTab === 'four' }" @click="changeTab('four')"
                    style="cursor: pointer;"> 举报处理</span>
                <span class="titles" :class="{ active: activeTab === 'five' }" @click="changeTab('five')"
                    style="cursor: pointer;"> 景点管理</span>
                <span class="titles" :class="{ active: activeTab === 'six' }" @click="changeTab('six')"
                    style="cursor: pointer;"> 系统通知</span>
            </div>
        </header>
        <aside>
            <img class="imgs" v-bind:src="admdata[0].imgsrc" />
            <div class="name">{{ admdata[0].name }}</div>
            <div class="name">
                <el-button @click="submitForm('ruleForm')">退出</el-button>
            </div>
        </aside>
        <main>
            <component :is="activeTab"></component>
        </main>
    </div>
</template>
  
<script>
import one from "./components/one.vue";
import two from "./components/two.vue";
import three from "./components/three.vue";
import four from "./components/four.vue";
import five from "./components/five.vue";
import six from "./components/six.vue";
export default {
    data() {
        return {
            activeTab: "one",
            admdata: [],
            img:''
        };
    },
    components: {
        one,
        two,
        three,
        four,
        five,
        six,
    },
    methods: {
        changeTab(tab) {
            this.activeTab = tab;
        },
        async submitForm(formName) {
            const baseUrl = window.location.href.split("#")[0];
            window.location.href = `${baseUrl}#/login`;
            localStorage.removeItem("aid");
            this.$message.success('退出成功')
        },
        getdata() {
            const aid = localStorage.getItem("aid");
            fetch(`http://localhost:3000/login/${aid}`, {
                method: 'GET'
            })
                .then(res => res.text())
                .then(res => {
                    this.admdata = JSON.parse(res)
                    // console.log(this.admdata[0])
                });
        },
    },
    mounted() {
        this.getdata();
    },
};
</script>
  
<style>
/* 左侧样式 */
aside {
    width: 200px;
    height: 100%;
    position: fixed;
    left: 0;
    top: 0;
    background-color: rgb(243, 238, 243);
}

/* 顶部样式 */
header {
    height: 80px;
    background-color: rgb(98, 151, 248);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1;
}

/* 在右侧显示的样式 */
main {
    margin-left: 200px;
    padding: 20px;
    box-sizing: border-box;
}

/*图片样式*/
.imgs {
    border-radius: 50%;
    width: 70%;
    height: auto;
    margin-left: 15%;
    margin-top: 150%;
    text-align: center;
}

/* 用户名样式*/
.name {
    width: 100%;
    height: 30px;
    margin-top: 50px;
    font-weight: bold;
    font-size: 20px;
    text-align: center;
}

/* 标题样式*/
.title {
    width: 100%;
    height: 30px;
    margin-top: 50px;
}

.titles {
    width: 150px;
    height: 30px;
    font-size: 15px;
    font-weight: bold;
    color: aliceblue;
    margin-left: 20px;
    margin-right: 8%;
}

.active {
    color: blue;
}
</style>